package com.myedu.draw;

import javax.swing.*;
import java.awt.*;

public class DrawCircle extends JFrame { //JFrame 对应窗口,可以理解成是一个画框
    private Plane plane = null;

    public static void main(String[] args) {
        new DrawCircle();
    }

    public DrawCircle() {
        //初始化面板
        plane = new Plane();
        //把面板放入到窗口中
        this.add(plane);
        //设置窗口的大小
        this.setSize(600, 400);
        //当点击窗口关闭按钮，退出程序
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        //可以显示
        this.setVisible(true);
    }
}

class Plane extends JPanel {
    @Override
    public void paint(Graphics g) {
        super.paint(g);
        //绘制圆形
        g.drawOval(10, 10, 100, 100);
    }
}
